package com.kevin.controller.admin;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.shiro.authc.DisabledAccountException;
import org.apache.shiro.authc.IncorrectCredentialsException;
import org.apache.shiro.authc.LockedAccountException;
import org.apache.shiro.authc.UnknownAccountException;
import org.apache.shiro.authc.pam.UnsupportedTokenException;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;


@Controller
public class LoginController{
	
	
	 @RequestMapping(value="/admin/login")
	 public String index(HttpServletRequest request, HttpServletResponse response) {
		 String errorClassName = (String)request.getAttribute("shiroLoginFailure");  
		 String msg=null;
        if(UnsupportedTokenException.class.getName().equals(errorClassName)) {  
        	msg="用户名/密码 不能为空";  
        } else if(UnknownAccountException.class.getName().equals(errorClassName)) {  
        	msg="用户名不存在";  
        } else if(DisabledAccountException.class.getName().equals(errorClassName)) {  
        	msg="该用户已被禁用";  
        } else if(LockedAccountException.class.getName().equals(errorClassName)) {  
        	msg="该用户已被锁定";  
        }  else if(IncorrectCredentialsException.class.getName().equals(errorClassName)) {  
        	msg="用户名/密码错误";  
        }else if(errorClassName != null) {  
        	msg="未知错误";  
        }  
	     request.setAttribute("error", msg);  
		 return "admin/login";
	 }
}
